﻿CREATE PROCEDURE [dbo].[SelectQuoteForDPICalc_SP]
	-- Add the parameters for the stored procedure here
@QuotelineitemID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
SELECT     QuoteLineItem_Tbl.*, Quote_Tbl.*, QuoteSailType_Tbl.CostSailtypeID, CostSailType_Tbl.Main
FROM       QuoteLineItem_Tbl INNER JOIN
           Quote_Tbl ON QuoteLineItem_Tbl.QuoteID = Quote_Tbl.QuoteID INNER JOIN
           QuoteSailType_Tbl ON QuoteLineItem_Tbl.QuoteSailtypeID = QuoteSailType_Tbl.QuoteSailTypeID
 inner join CostSailType_Tbl on CostSailType_Tbl.CostSailTypeID = 
(Select QuoteSailType_Tbl.CostSailTypeID from QuoteSailType_Tbl 
where QuoteLineItem_Tbl.QuoteSailtypeID = QuoteSailType_Tbl.QuoteSailTypeID)
		Where QuoteLineItem_Tbl.QuoteLineitemID=@QuoteLineitemID		
END